package com.usian.wemedia.controller;

import com.usian.apis.wemedia.WmmaterialControllerApi;
import com.usian.common.contants.wemedia.WemediaContans;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.media.dtos.WmMaterialDto;
import com.usian.wemedia.service.WmmaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/api/v1/material")
public class WmmaterialController implements WmmaterialControllerApi {
    @Autowired
    WmmaterialService service;
    @Override
    @PostMapping("/upload")
    public ResponseResult uploadFile(MultipartFile file) {
        return service.upload(file);
    }

    @Override
    @PostMapping("/findList")
    public ResponseResult findList(@RequestBody WmMaterialDto dto) {
        return service.findList(dto);
    }

    @Override
    @GetMapping("/delFile/{id}")
    public ResponseResult delFile(@PathVariable Integer id) {
        return service.delFile(id);
    }

    @Override
    @GetMapping("/cancleCollection/{id}")
    public ResponseResult cancleCollectionMaterial(@PathVariable Integer id) {
        return service.updateById(id, WemediaContans.CANCEL_COLLECT_MATERIAL);
    }

    @Override
    @GetMapping("/collection/{id}")
    public ResponseResult collectionMaterial(@PathVariable Integer id) {
        return service.updateById(id,WemediaContans.COLLECT_MATERIAL);
    }
}
